<div class="content">
    <div id="example_title">
        <h1>Render to a New Box</h1>
        When you create a grid it is not required to provide a container, thus it creates a grid in memory.
        The example below illustrates how to create a grid in memory and render it when needed and where needed.
    </div>
    <div id="example_view"></div>
    <div id="example_code"></div>
</div>

<!--CODE-->
<div style="position: relative; height: 300px;">
    <div id="grid1" style="display: inline-block; width: 500px; height: 300px; border: 2px solid green;"></div>
    <div id="grid2" style="display: inline-block; width: 500px; height: 300px; border: 2px solid red;"></div>
</div>
<br>
<button class="w2ui-btn" onclick="render('#grid1')">Render into Green Box</button>
<button class="w2ui-btn" onclick="render('#grid2')">Render into Red Box</button>

<!--CODE-->
<script type="module">
import { w2grid } from '__W2UI_PATH__'

let grid = new w2grid({
    name: 'grid',
    columns: [
        { field: 'recid', text: 'ID', size: '50px', sortable: true, attr: 'align=center' },
        { field: 'lname', text: 'Last Name', size: '30%', sortable: true },
        { field: 'fname', text: 'First Name', size: '30%', sortable: true },
        { field: 'email', text: 'Email', size: '40%' },
        { field: 'sdate', text: 'Start Date', size: '120px' }
    ],
    records: [
        { recid: 1, fname: 'Jane', lname: 'Doe', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 3, fname: 'Jin', lname: 'Franson', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 4, fname: 'Susan', lname: 'Ottie', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 5, fname: 'Kelly', lname: 'Silver', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 6, fname: 'Francis', lname: 'Gatos', email: 'jdoe@gmail.com', sdate: '4/3/2012' }
    ]
})

window.render = function(box) {
    grid.render(box)
}
</script>
